// 分组和分支结构

// f匹配连续的ab
var string ="aba abb abab"
var regex=/(ab)+/g;
console.log(string.match(regex));//[ 'ab', 'ab', 'abab' ]

var regex=/ab+/g;
console.log(string.match(regex));//[ 'ab', 'abb', 'ab', 'ab' ]

// 分支结构造中 对比两种情况
var regex = /^I love (JavaScript|Regular Expression)$/;
console.log( regex.test("I love JavaScript") );
console.log( regex.test("I love Regular Expression") );

var regex2 = /^I love JavaScript|Regular Expression$/g;
// console.log( regex2.test("I love JavaScript") );
// console.log( regex2.test("I love Regular Expression") );
console.log("I love JavaScript I love Regular Expression".match(regex2));

